class_name Interactable extends Area2D

signal interacted

func _init() -> void:
	# 只能找到玩家
	collision_layer = 0
	collision_mask = 0
	set_collision_mask_value(2,true)

	body_entered.connect(_on_body_enter)
	body_exited.connect(_on_body_exit)

func _on_body_enter(player:Player) -> void:
	player.register_interact_with(self)

func _on_body_exit(player:Player) -> void:
	player.unregister_interact_with(self)
	
func interact() -> void:
	print("interact:%s"%name)
	interacted.emit()
	
